﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin.Master" AutoEventWireup="true" CodeBehind="ActivityManage.aspx.cs" Inherits="MobileServer.Web.Admin.WebForm1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" 
        DataKeyNames="ID" DataSourceID="SqlDataSource1" DefaultMode="Insert" 
        EnableModelValidation="True" Height="50px">
        <Fields>
            <asp:BoundField DataField="StartDate" HeaderText="StartDate" 
                SortExpression="StartDate" />
            <asp:CheckBoxField DataField="IsEnd" HeaderText="IsEnd" 
                SortExpression="IsEnd" />
            <asp:BoundField DataField="Description" HeaderText="Description" 
                SortExpression="Description" />
            <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
            <asp:TemplateField HeaderText="Manager" SortExpression="Manager">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Manager") %>'></asp:TextBox>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:DropDownList ID="DropDownList3" runat="server" AppendDataBoundItems="True" 
                        DataSourceID="SqlDataSource3" DataTextField="Name" DataValueField="Id" 
                        SelectedValue='<%# Bind("Manager") %>'>
                        <asp:ListItem></asp:ListItem>
                    </asp:DropDownList>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("Manager") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="Tickte" HeaderText="Tickte" 
                SortExpression="Tickte" />
            <asp:CheckBoxField DataField="IsSMS" HeaderText="IsSMS" 
                SortExpression="IsSMS" />

            <asp:CommandField ShowInsertButton="True" />
        </Fields>
    </asp:DetailsView>
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        DataKeyNames="ID" DataSourceID="SqlDataSource1" EnableModelValidation="True">
        <Columns>
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
            <asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="True" 
                SortExpression="ID" />
            <asp:BoundField DataField="StartDate" HeaderText="StartDate" 
                SortExpression="StartDate" />
            <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
            <asp:CheckBoxField DataField="IsEnd" HeaderText="IsEnd" 
                SortExpression="IsEnd" />
            <asp:BoundField DataField="Description" HeaderText="Description" 
                SortExpression="Description" />
            <asp:TemplateField HeaderText="Manager" SortExpression="Manager">
                <EditItemTemplate>
                    <asp:DropDownList ID="DropDownList3" runat="server" AppendDataBoundItems="True" 
                        DataSourceID="SqlDataSource3" DataTextField="Name" DataValueField="Id" 
                        SelectedValue='<%# Bind("Manager") %>'>
                        <asp:ListItem></asp:ListItem>
                    </asp:DropDownList>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("ManagerName") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="Tickte" HeaderText="Tickte" 
                SortExpression="Tickte" />
            <asp:CheckBoxField DataField="IsSMS" HeaderText="IsSMS" 
                SortExpression="IsSMS" />
            <asp:TemplateField HeaderText="名单">
                <ItemTemplate>
                    <asp:HyperLink NavigateUrl='<%#Eval("Id", "CurrentActivityUser.aspx?Id={0}") %>' Visible='<%#!((bool)Eval("IsEnd")) %>' Text="活动名单" runat="server" />
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:DefaultDB %>" 
        DeleteCommand="DELETE FROM [Bis_Activity] WHERE [ID] = @ID" 
        InsertCommand="INSERT INTO [Bis_Activity] ([StartDate], [IsEnd], [Description], [Title],[Manager],[Tickte],[IsSMS]) VALUES (@StartDate, @IsEnd, @Description, @Title, @Manager, @Tickte, @IsSMS)" 
        SelectCommand="SELECT *, (select [Name] from sec_user where sec_user.Id= Bis_Activity.Manager) as [ManagerName] FROM [Bis_Activity] ORDER BY [StartDate] DESC" 
        UpdateCommand="UPDATE [Bis_Activity] SET [StartDate] = @StartDate, [IsEnd] = @IsEnd, [Description] = @Description, [Title] = @Title, [Manager] = @Manager,[Tickte] = @Tickte, [IsSMS]=@IsSMS WHERE [ID] = @ID">
        <DeleteParameters>
            <asp:Parameter Name="ID" Type="Object" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="StartDate" Type="DateTime" />
            <asp:Parameter Name="IsEnd" Type="Boolean" />
            <asp:Parameter Name="Description" Type="String" />
            <asp:Parameter Name="Title" Type="String" />
            <asp:Parameter Name="Manager" />
            <asp:Parameter Name="Tickte" Type="Int32" />
            <asp:Parameter Name="IsSMS" Type="Boolean" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="StartDate" Type="DateTime" />
            <asp:Parameter Name="IsEnd" Type="Boolean" />
            <asp:Parameter Name="Description" Type="String" />
            <asp:Parameter Name="Title" Type="String" />
            <asp:Parameter Name="ID" Type="Object" />
            <asp:Parameter Name="Manager" />
            <asp:Parameter Name="Tickte" Type="Int32" />
            <asp:Parameter Name="IsSMS" Type="Boolean" />
        </UpdateParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
        ConnectionString="<%$ ConnectionStrings:DefaultDB %>" 
        SelectCommand="SELECT [Id], [Name] FROM [SEC_User] ORDER BY [Name]"></asp:SqlDataSource>

</asp:Content>
